package com.test.test11;

import com.test.test11.entity.User;
import com.test.test11.entity.UserDeviceRelationship;

import java.util.List;

/**
 * 存储常驻内存中的数据
 */

public class SharedConstants {
    private static final String TAG = "SHARED_CONSTANTS";

    //存储当前登录用户的信息
    public static User CURRENT_USER;

    //存储该用户的所有用户列表
    public static List<UserDeviceRelationship> deviceList;

    /**
     * 更新当前登陆用户
     * @param user
     */
    public synchronized static void updateUser(User user){
        CURRENT_USER = user;
    }

    public static synchronized void addDevice(UserDeviceRelationship userDeviceRelationship){
        deviceList.add(userDeviceRelationship);
    }

    public static synchronized void deleteDevice(UserDeviceRelationship userDeviceRelationship){
        deviceList.remove(userDeviceRelationship);
    }

    public static synchronized void setDeviceList(List<UserDeviceRelationship> list){
        deviceList = list;
    }

    public static List<UserDeviceRelationship> getDeviceList(){
        System.out.println("5644537884637");
        return deviceList;
    }
}
